<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .box1{
        height: 300px;
        width: 600px;
        border: 2px solid skyblue;
        margin: 0 auto;
        text-align: center
    }
    .box2{
        height:50px ;
        width: 600px;
        
    }
    #kaishi{
        width: 100px;
        height: 50px;
    }
    #jieshu{
        width: 100px;
        height: 50px;
    }
</style>
<body>
    
    <div class="box1"><b style="font-size: 20px;">随机问答</b><br><br><br>
    <div class="box2">抽</div><br><br><br>
    <button id="kaishi">开始</button>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <button id="jieshu">结束</button>
<script>
    let timer = null
    const arrName=["范宇杭","梁鑫","彭家洋","彭志轩","黄中旺","范老师","万里鹏","陈政睿"]
    const kaishi = document.querySelector('#kaishi')
    const jieshu = document.querySelector('#jieshu')
    const box2 = document.querySelector('.box2')
    kaishi.addEventListener('click',function(){
        timer = setInterval(function(){
        const ran = Math.floor(Math.random() * arrName.length)
        box2.innerHTML = arrName[ran]},50);
    },)
    jieshu.addEventListener('click',function(){
        clearInterval(timer) 
        const selectedName = box2.innerHTML; 
        const index = arrName.indexOf(selectedName);
        if (index !== -1){
            arrName.splice(index, 1);
        }
    })
   
   
</script>
    </div>
</body>
</html>